package org.apix.commands.command;

import org.apix.Apix;
import org.apix.commands.BaseCommand;

import org.bukkit.entity.Player;

public class T extends BaseCommand {

	@Override
	public boolean execute(Player p, org.bukkit.command.Command command, String[] args){
		if(!isEnabled()) {
			return false;
		}
		
		if(!this.defaultCommandChecks(p)) {
			return true;
		}
		
		
		if(args.length > 0) {
			if(args[0].equalsIgnoreCase(p.getName()) ) {
				p.sendMessage("Teleport yourself to yourself? Sure?");
			} else {
				for (Player pl : p.getWorld().getPlayers()) {
					
					if(pl.isOnline()) {
						if(pl.getName().equalsIgnoreCase(args[0]) ) {
							p.teleport(pl.getLocation());
							Apix.log.info(" Teleporting " + p.getName() + " to" + args[0]);
							return true;
						}
					}
					
				}
				p.sendMessage(args[0] +" is Offline");
			}
		}
		else {
			p.sendMessage("Usage:");
			p.sendMessage("  /t <username>");
		}		
		
		
		return true;
	}
}
